package com.jxpanda.infrastructure.crypto.algorithm.encrypt;

import com.jxpanda.infrastructure.crypto.algorithm.encrypt.contract.AbstractAsymmetricEncrypt;
import com.jxpanda.infrastructure.crypto.constant.AlgorithmEncrypt;

import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.PublicKey;

public class RsaEncrypt extends AbstractAsymmetricEncrypt {

    public RsaEncrypt(KeyPair keyPair) {
        this(AlgorithmEncrypt.RSA.RSA, keyPair);
    }

    public RsaEncrypt(AlgorithmEncrypt.RSA rsa, KeyPair keyPair) {
        super(rsa.getAlgorithm(), keyPair);
    }


    public RsaEncrypt(AlgorithmEncrypt.RSA rsa, PublicKey publicKey) {
        super(rsa.getAlgorithm(), publicKey);
    }

    public RsaEncrypt(AlgorithmEncrypt.RSA rsa, PrivateKey privateKey) {
        super(rsa.getAlgorithm(), privateKey);
    }

    public RsaEncrypt(AlgorithmEncrypt.RSA rsa, PublicKey publicKey, PrivateKey privateKey) {
        super(rsa.getAlgorithm(), publicKey, privateKey);
    }

    public static RsaEncrypt createDefault() {
        return AlgorithmEncrypt.RSA.RSA.builder().buildDefault();
    }

    public static RsaEncrypt.Builder builder(AlgorithmEncrypt.RSA rsa) {
        return new Builder(rsa);
    }

    public static class Builder extends AbstractAsymmetricEncrypt.Builder<AlgorithmEncrypt.RSA, RsaEncrypt> {
        protected Builder(AlgorithmEncrypt.RSA rsa) {
            super(rsa);
        }
    }

}
